$(function () {
    $(".synthesis").on("click", function () {
        $(".synthesis").removeClass("options")
        $(this).addClass("options")
    })
    $(".chronological-ordering").on("click", function () {
        let accountId = $(".body").attr("account-id");
        let name = $(".body").attr("name");
        let id = $(".body").attr("id");
        let searchValue = $(".body").attr("search-input");
        //加密
        let aesKeyUtil = new Aes_key_util();
        const encryptedInformationId = aesKeyUtil.encrypt(id);
        window.location.href = "/www.xiaomi.com/search?searchInput=" + searchValue
            + "&accountId=" + accountId
            + "&name=" + name
            + "&id=" + encodeURIComponent(encryptedInformationId)
            + "&order=shelf_time"
            + "&isAsc=1"
            + "&sortColor=2"
    })
    $(".comprehensive-sorting").on("click",function () {
        let accountId = $(".body").attr("account-id");
        let name = $(".body").attr("name");
        let id = $(".body").attr("id");
        let searchValue = $(".body").attr("search-input");
        //加密
        let aesKeyUtil = new Aes_key_util();
        const encryptedInformationId = aesKeyUtil.encrypt(id);
        window.location.href = "/www.xiaomi.com/search?searchInput=" + searchValue
            + "&accountId=" + accountId
            + "&name=" + name
            + "&id=" + encodeURIComponent(encryptedInformationId)
            + "&sortColor=1"
    })
    $(".price-sorting").on("click",function () {
        let accountId = $(".body").attr("account-id");
        let name = $(".body").attr("name");
        let id = $(".body").attr("id");
        let searchValue = $(".body").attr("search-input");
        //加密
        let aesKeyUtil = new Aes_key_util();
        const encryptedInformationId = aesKeyUtil.encrypt(id);
        window.location.href = "/www.xiaomi.com/search?searchInput=" + searchValue
            + "&accountId=" + accountId
            + "&name=" + name
            + "&id=" + encodeURIComponent(encryptedInformationId)
            + "&order=commodity_price"
            + "&isAsc=1"
            + "&sortColor=3"
    })
    $(".content").on("click",function () {
        let commodityId = $(this).attr("commodity-id")
        let accountId = $(".body").attr("account-id");
        let name = $(".body").attr("name");
        let id = $(".body").attr("id");
        //加密
        let aesKeyUtil = new Aes_key_util();
        const encryptedInformationId = aesKeyUtil.encrypt(id);
        window.open("/www.xiaomi.com/product/details?informationId=" +
            encodeURIComponent(encryptedInformationId) + "&commodityId=" + commodityId + "&accountId=" + accountId +
            "&name=" + name, "_blank");
    })
    $(".last").on("click",function () {
        let commodityId = $(this).attr("commodity-id")
        let accountId = $(".body").attr("account-id");
        let name = $(".body").attr("name");
        let id = $(".body").attr("id");
        let totalPages = $(".pagination").attr("total-pages");
        //加密
        let aesKeyUtil = new Aes_key_util();
        const encryptedInformationId = aesKeyUtil.encrypt(id);
        window.location.href = "/www.xiaomi.com/search?accountId="+
            accountId+"&name="+
            name+"&id="+
            encodeURIComponent(encryptedInformationId)+
            "&pageNumber="+totalPages
    })
    $(".next").on("click",function () {
        let commodityId = $(this).attr("commodity-id")
        let accountId = $(".body").attr("account-id");
        let name = $(".body").attr("name");
        let id = $(".body").attr("id");
        let pageNumber = $(this).attr("page-number")
        //加密
        let aesKeyUtil = new Aes_key_util();
        const encryptedInformationId = aesKeyUtil.encrypt(id);
        window.location.href = "/www.xiaomi.com/search?accountId="+
            accountId+"&name="+
            name+"&id="+
            encodeURIComponent(encryptedInformationId)+
            "&pageNumber="+pageNumber
    })
    $(".specify-page").on("click",function () {
        let commodityId = $(this).attr("commodity-id")
        let accountId = $(".body").attr("account-id");
        let name = $(".body").attr("name");
        let id = $(".body").attr("id");
        let pageNumber = $(this).attr("page-number")
        //加密
        let aesKeyUtil = new Aes_key_util();
        const encryptedInformationId = aesKeyUtil.encrypt(id);
        window.location.href = "/www.xiaomi.com/search?accountId="+
            accountId+"&name="+
            name+"&id="+
            encodeURIComponent(encryptedInformationId)+
            "&pageNumber="+pageNumber
    })
    $(".previous").on("click",function () {
        let commodityId = $(this).attr("commodity-id")
        let accountId = $(".body").attr("account-id");
        let name = $(".body").attr("name");
        let id = $(".body").attr("id");
        let pageNumber = $(this).attr("page-number")
        //加密
        let aesKeyUtil = new Aes_key_util();
        const encryptedInformationId = aesKeyUtil.encrypt(id);
        window.location.href = "/www.xiaomi.com/search?accountId="+
            accountId+"&name="+
            name+"&id="+
            encodeURIComponent(encryptedInformationId)+
            "&pageNumber="+pageNumber
    })
    $(".home-page").on("click",function () {
        let commodityId = $(this).attr("commodity-id")
        let accountId = $(".body").attr("account-id");
        let name = $(".body").attr("name");
        let id = $(".body").attr("id");
        let pageNumber = $(this).attr("page-number")
        //加密
        let aesKeyUtil = new Aes_key_util();
        const encryptedInformationId = aesKeyUtil.encrypt(id);
        window.location.href = "/www.xiaomi.com/search?accountId="+
            accountId+"&name="+
            name+"&id="+
            encodeURIComponent(encryptedInformationId)+
            "&pageNumber=1"
    })
})